﻿// -----------------------------------------------------------------------
// <copyright file="ThrowTest.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace WpfDevelopment.MVVM.Tests.Internal
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using WpfDevelopment.MVVM;
    using System;

    [TestClass]
    public class ThrowTest   
    {   
        [TestClass]
        public class When
        {
            [TestMethod, ExpectedException(typeof(ArgumentException))]
            public void Must_throw_exception_if_condition_is_true()
            {
                // Act
                Throw<ArgumentException>.When(true, "test", "test");
            }

            [TestMethod]
            public void Must_not_throw_exception_if_condition_is_false()
            {
                // Act
                Throw<ArgumentException>.When(false, "test", "test");

                // Arrange => no exception thrown, is ok.
            }

            [TestMethod, ExpectedException(typeof(ArgumentNullException), "1")]
            public void Must_throw_argumentNullException_with_correct_argument_order()
            {
                // Act
                Throw<ArgumentNullException>.When(true, "1", "2");
            }

            [TestMethod, ExpectedException(typeof(ArgumentException), "1")]
            public void Must_throw_argumentException_with_correct_argument_order()
            {
                // Act
                Throw<ArgumentException>.When(true, "1", "2");
            }

            [TestMethod, ExpectedException(typeof(ArgumentException), "")]
            public void Must_throw_argumentException_with_string_empty_if_no_params_given()
            {
                // Act
                Throw<ArgumentException>.When(true, "1");
            }
        }

        [TestClass]
        public class WhenNot
        {
            [TestMethod]
            public void Must_not_throw_exception_if_condition_is_true()
            {
                // Act
                Throw<ArgumentException>.WhenNot(true, "test", "test");

                // Arrange => no exception thrown, is ok.
            }

            [TestMethod, ExpectedException(typeof(ArgumentException))]
            public void Must_throw_exception_if_condition_is_false()
            {
                // Act
                Throw<ArgumentException>.WhenNot(false, "test", "foo");
            }

            [TestMethod, ExpectedException(typeof(ArgumentNullException), "1")]
            public void Must_throw_argumentNullException_with_correct_argument_order()
            {
                // Act
                Throw<ArgumentNullException>.WhenNot(false, "1", "2");
            }
        }
    }
}
